<template>

</template>

<script>
import useTabs from "@/utils/useTabs";

export default {
  data() {
    return {}
  },
  async mounted() {
    let queryParams = this.$route.query;
    if (queryParams.documentId) {
      let res = await this.$API.asset.document.findById.post({id: queryParams.documentId});
      if (res.code === 2000) {
        let data = res.data;
        if (data) {
          let document = data;
          this.$nextTick(() => {
            let fromRouteId = this.$TOOL.crypto.MD5("/index")
            let configId = document.documentConfigId;
            let documentId = document.id;
            this.$router.replace({path: '/documentPrepare/' + fromRouteId + '/' + configId + '/' + documentId})

          })
        } else {
          this.$message.warning("单据信息不存在");
        }
      } else {
        this.$message.warning("获取单据信息失败");
      }
    } else if (queryParams.tiid) {
      let data = {other: {}};
      data.other.tiid = queryParams.tiid;
      let res = await this.$API.asset.document.listData.post(data);
      if (res.code === 2000) {
        let data = res.data;
        if (data[0]) {
          let document = data[0];
          this.$nextTick(() => {
            let fromRouteId = this.$TOOL.crypto.MD5("/index")
            let configId = document.documentConfigId;
            let documentId = document.id;
            this.$router.replace({path: '/documentPrepare/' + fromRouteId + '/' + configId + '/' + documentId})

          })
        } else {
          this.$message.warning("单据信息不存在");
        }
      } else {
        this.$message.warning("获取单据信息失败");
      }
    } else {
      this.$message.warning("参数错误");
    }
    useTabs.close();
  }
}
</script>
